{% extends "catalog/base_generic.html" %}

{% block title %}{{ author.name }} - 作者详情{% endblock %}

{% block content %}
<div class="card">
    <div class="card-body">
        <div class="d-flex justify-content-between align-items-start mb-4">
            <div>
                <h1 class="card-title h2 mb-3">
                    <i class="fas fa-user-edit me-2"></i>{{ author.name }}
                </h1>
                <p class="text-muted mb-3">
                    <i class="fas fa-birthday-cake me-2"></i>
                    {% if author.date_of_birth %}{{ author.date_of_birth|date:"Y年m月d日" }}{% else %}未知{% endif %}
                    {% if author.date_of_death %} - {{ author.date_of_death|date:"Y年m月d日" }}{% endif %}
                </p>
            </div>
            {% if perms.catalog.can_mark_returned %}
            <div>
                <a href="{% url 'author-update' author.pk %}" class="btn btn-outline-secondary me-2">
                    <i class="fas fa-edit me-1"></i>编辑作者
                </a>
                <a href="{% url 'author-delete' author.pk %}" class="btn btn-outline-danger">
                    <i class="fas fa-trash me-1"></i>删除作者
                </a>
            </div>
            {% endif %}
        </div>

        <div class="card mb-4">
            <div class="card-body bg-light">
                <h5 class="card-title">
                    <i class="fas fa-info-circle me-2"></i>作者简介
                </h5>
                <p class="card-text">{{ author.bio|linebreaks }}</p>
            </div>
        </div>

        <h5 class="card-title mb-4">
            <i class="fas fa-book me-2"></i>作品列表
        </h5>
        
        <div class="row g-4">
            {% for book in author.book_set.all %}
            <div class="col-md-6">
                <div class="card h-100">
                    <div class="card-body">
                        <h5 class="card-title">{{ book.title }}</h5>
                        <p class="card-text text-muted">
                            <small>
                                <i class="fas fa-language me-1"></i>{{ book.language }}
                                <span class="mx-2">|</span>
                                <i class="fas fa-hashtag me-1"></i>{{ book.isbn }}
                            </small>
                        </p>
                        <p class="card-text">{{ book.summary|truncatewords:30 }}</p>
                        <div class="mb-3">
                            {% for genre in book.genre.all %}
                            <span class="badge bg-secondary me-1">{{ genre }}</span>
                            {% endfor %}
                        </div>
                        <div class="d-flex justify-content-between align-items-center">
                            <a href="{{ book.get_absolute_url }}" class="btn btn-sm btn-outline-primary">
                                <i class="fas fa-info-circle me-1"></i>查看详情
                            </a>
                            {% if perms.catalog.can_mark_returned %}
                            <div>
                                <a href="{% url 'book-update' book.pk %}" class="btn btn-sm btn-outline-secondary">
                                    <i class="fas fa-edit me-1"></i>编辑
                                </a>
                                <a href="{% url 'book-delete' book.pk %}" class="btn btn-sm btn-outline-danger">
                                    <i class="fas fa-trash me-1"></i>删除
                                </a>
                            </div>
                            {% endif %}
                        </div>
                    </div>
                </div>
            </div>
            {% empty %}
            <div class="col-12">
                <div class="alert alert-info">
                    <i class="fas fa-info-circle me-2"></i>该作者暂无作品
                </div>
            </div>
            {% endfor %}
        </div>
    </div>
</div>
{% endblock %} 